<template>
	<!-- 查看详情 -->
	<el-dialog
		:title="$t('game.game_betslip.note_details')"
		:visible.sync="visible"
		width="1500px"
		@close="2"
	>
		<div class="game-container report-container">
			<div class="view-container dealer-container">
				<notedetails
					:dataList="lookMsgList"
					:lookMsgList="lookMsgList"
				></notedetails>
				<div v-for="(detailItem, index) in betHisDetails" :key="index">
					<realDetails
						v-if="venueTypeCode === 'zr'"
						:dataList="detailItem"
						:lookMsgList="lookMsgList"
					></realDetails>
					<chessDetails
						v-else-if="venueTypeCode === 'qp'"
						:dataList="detailItem"
						:lookMsgList="lookMsgList"
					></chessDetails>
					<sportDetails
						v-else-if="venueTypeCode === 'ty'"
						:dataList="detailItem"
						:lookMsgList="lookMsgList"
					></sportDetails>
					<eSportDetails
						v-else-if="venueTypeCode === 'dj'"
						:dataList="detailItem"
						:lookMsgList="lookMsgList"
					></eSportDetails>
					<lotteryDetails
						v-else-if="venueTypeCode === 'cp'"
						:dataList="detailItem"
						:lookMsgList="lookMsgList"
					></lotteryDetails>
					<eGameDetails
						v-else-if="venueTypeCode === 'dy'"
						:dataList="detailItem"
						:lookMsgList="lookMsgList"
					></eGameDetails>
					<regionalChain
						v-else-if="venueTypeCode === 'qkl'"
						:dataList="detailItem"
						:lookMsgList="lookMsgList"
					></regionalChain>
					<dzDetails
						v-else-if="venueTypeCode === 'DZ_CARD'"
						:dataList="detailItem"
						:parentBetTypes="parentBetTypes"
						:parentBetSubTypes="parentBetSubTypes"
						:lookMsgList="lookMsgList"
					></dzDetails>
					<slotDetails
						v-else
						:dataList="detailItem"
						:lookMsgList="lookMsgList"
					></slotDetails>
				</div>
			</div>

			<div
				class="bill-table"
				style="padding: 30px"
				v-if="billDetails && billDetails.length > 0"
			>
				<h2>关联账变记录</h2>
				<BillTable :tableData="billDetails" />
			</div>
		</div>
	</el-dialog>
	<!-- 投注详情 -->
</template>

<script>
import notedetails from '@/views/game/gameBetslip/gameBetslipTable/components/Notedetails'
import realDetails from '@/views/game/gameBetslip/gameBetslipTable/components/realDetails'
import chessDetails from '@/views/game/gameBetslip/gameBetslipTable/components/chessDetails'
import sportDetails from '@/views/game/gameBetslip/gameBetslipTable/components/sportDetails'
import eSportDetails from '@/views/game/gameBetslip/gameBetslipTable/components/eSportDetails'
import lotteryDetails from '@/views/game/gameBetslip/gameBetslipTable/components/lotteryDetails'
import eGameDetails from '@/views/game/gameBetslip/gameBetslipTable/components/eGameDetails'
import slotDetails from '@/views/game/gameBetslip/gameBetslipTable/components/slotDetails'
import dzDetails from '@/views/game/gameBetslip/gameBetslipTable/components/dzDetails'
import regionalChain from '@/views/game/gameBetslip/gameBetslipTable/components/regionalChain'
import BillTable from './billTable.vue'

export default {
  components: {
    notedetails,
    realDetails,
    chessDetails,
    sportDetails,
    eSportDetails,
    lotteryDetails,
    eGameDetails,
    slotDetails,
    regionalChain,
    dzDetails, // 德州详情
    BillTable
  },
  props: {
    lookMsgList: {
      type: Object
    },
    value: {
      type: Boolean
    }
  },
  data() {
    return {
      visible: false,
      betHisDetails: [],
      dataList: [],
      billDetails: []
    }
  },
  computed: {
    venueTypeCode() {
      return this.lookMsgList.venueTypeCode
    }
  },
  watch: {
    value: {
      handler(val) {
        this.visible = val
      },
      immediate: true
    },
    visible(newVal) {
      this.$emit('input', newVal)
    }
  },
  created() {
    this.getdetailsdata()
  },

  methods: {
    getdetailsdata(val = this.lookMsgList, flag) {
      const data = {
        eventIds: val.eventIds
      }
      data.id = val.id
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      this.dataList = {}
      this.betHisDetails = []
      // 是否重算
      if (val.obSettleCount > 0) {
        this.$api.venueAbnormalGetResettlementGameRecordDetails(data)
          .then((res) => {
            if (res.code === 200) {
              this.betHisDetails = res.data.resettlementBetDetailDto?.betHisDetails
              this.billDetails = res.data.billDetails
              this.dataList = res.data
            }

            loading.close()
          })
          .catch(() => {
            loading.close()
          })
        return
      }
      this.$api.venueAbnormalGetGameRecordDetails(data)
        .then((res) => {
          if (res?.code === 200) {
            this.dataList = res.data.betDetailDto
            this.betHisDetails = [res.data.betDetailDto]
            this.billDetails = res.data.billDetails || []
            loading.close()
          }
        })
        .catch(() => {
          loading.close()
        })
    }
  }
}

</script>
